package com.bootx.service.impl;

import com.bootx.entity.OpenAiConfig;
import com.bootx.service.OpenAiConfigService;
import org.springframework.stereotype.Service;

/**
 * @author black
 */
@Service
public class OpenAiConfigServiceImpl extends BaseServiceImpl<OpenAiConfig,Long> implements OpenAiConfigService {
    @Override
    public void updateCount(Integer count) {
        try {
            jdbcTemplate.update("update openaiconfig set remainCount=remainCount+"+(count*2)+" where id=1;");
        }catch (Exception e){
            e.printStackTrace();
        }
    }

    @Override
    public Integer getCount() {
        try {
            return jdbcTemplate.queryForObject("select remainCount from openaiconfig where id=1;",Integer.class);
        }catch (Exception ignored){
            return 0;
        }
    }
}
